import java.util.Arrays;

public class Test {
    public static void  func(int[] tmp1) {
        tmp1 = new int[10];
       // tmp1 = {1,2,3,4,5};
    }

    public static void func4(int[] tmp1) {
        tmp1[0] = 99;
    }
    public static void main(String[] args) {
        int[] array = {1,2,3,4};
        System.out.println(array.length);
        int[] array2 = array;

        int[] array3 = null;
        //System.out.println(array3[0]);

        int[] array4 = new int[]{1,2,3,4,5};//开辟了一块新的内存


        int[] array5;
        array5 = new int[]{1,2,3,4,5};
    }





    public static void swap(int[] array) {
        int tmp = array[0];
        array[0] = array[1];
        array[1] = tmp;
    }

    public static void main6(String[] args) {
        int[] tmp = {1,2};
        System.out.println("交换前："+tmp[0]+" "+tmp[1]);
        swap(tmp);
        System.out.println("交换后："+tmp[0]+" "+tmp[1]);
    }
    public static int[] func3() {
        int[] tmp = {1,2,3,4,5,6,7};
        return tmp;
    }
    public static void main5(String[] args) {
        int a = 10;
        int[] ret = func3();
        System.out.println(Arrays.toString(ret));
    }
    public static void func1(int[] array) {
        array = new int[10];
    }

    public static void func2(int[] array) {
        array[0] = 99;
    }
    public static void main4(String[] args) {
        int[] array = {1,2,3,4};
        func1(array);
        System.out.println(Arrays.toString(array));
        func2(array);
        System.out.println(Arrays.toString(array));
    }
    public static void main3(String[] args) {
        int[] array = {1,2,3,4};
        System.out.println(Arrays.toString(array));//1234

        int[] array2 = array;
        array2[1] = 99;
        System.out.println(Arrays.toString(array));//
        System.out.println(Arrays.toString(array2));//

    }
    public static void main2(String[] args) {
        int a = 10;
        int b = 10;
        int[] array = {1,2,3,4};
        System.out.println(array);
    }
    public static void main1(String[] args) {
        //三种定义数组的方式
        //前两种为数组的定义并且初始化
        //后一种为数组的定义，并无初始化，只是分配了数组的大小为10
        int[] array1 = {1,2,3,4};
        int[] array2 = new int[]{1,2,3,4};
        int[] array3 = new int[10];
    }
}
